<?php

class Project extends CActiveRecord
{
  public $is_default = false;
  public $is_editable = true;
  public $name;
  public $details;
	/**
	 * Returns the static model of the specified AR class.
	 * @return CActiveRecord the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'project';
	}

        /**
	 * @return array relational rules.
	 */
	public function relations()
	{
		return array(
			'user'=>array(self::BELONGS_TO, 'User', 'id_user'),
                        'progress'=>array(self::HAS_MANY, 'Progress', 'id_project'),
		);
	}

        static public function defaultOne($position) {
          $model = new Project();
          $model->is_default=true;
          $model->is_editable=Yii::app()->user->isGuest ? false : true;
          $model->position=$position;
          $model->name='libre';
          $model->details="apunta aquí los ideas que se te pasan por la cabeza, cosas concretas y de verdad importantes, sin detallar, solo ideas, o pasos a seguir!";
          return $model;
        }


}